package com.example.guiguihomemedical.controller;

import com.example.guiguihomemedical.common.Result;
import com.example.guiguihomemedical.entity.Servicesigning;
import com.example.guiguihomemedical.entity.Signing;
import com.example.guiguihomemedical.service.ServicesigningService;
import com.example.guiguihomemedical.service.SigningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("servicesigning")
public class ServicesigningController {
    @Autowired
    private ServicesigningService servicesigningService;
    @GetMapping
    public Result getAll(){
        List<Servicesigning> servicesigningList=servicesigningService.getAll();
        return Result.success(servicesigningList);
    }
    @DeleteMapping("/{idcard}")
    public Result delete(@PathVariable String idcard){
        servicesigningService.delete(idcard);
        return Result.success();
    }

    @PostMapping
    public Result add(@RequestBody Servicesigning servicesigning){
        servicesigningService.add(servicesigning);
        return Result.success();
    }

    @GetMapping("/{idcard}")
    public Result getById(@PathVariable String idcard){
        Servicesigning servicesigning = servicesigningService.getByIdcard(idcard);
        return Result.success(servicesigning);
    }
}
